package com.chenpeijian.demo.demos.web.vo;

import com.chenpeijian.demo.common.CustomValidPhone;
import com.chenpeijian.demo.demos.web.vo.group.RegisterGroup;
import com.chenpeijian.demo.demos.web.vo.group.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

/**
 * @program: student_code
 * @description:
 * @author: 陈培建
 * @create: 2024-12-12 19:11
 **/
@Data
public class UserRequest {
    @Schema(description = "用户名")
    @NotEmpty
    @NotNull(groups = RegisterGroup.class, message = "用户名不能为空")
    @Size(min = 3, max = 20, groups = RegisterGroup.class, message = "用户名长度必须在3到20之间")
    private String username;
    @Schema(description = "密码")
    @NotEmpty(groups = RegisterGroup.class)
    @NotNull(groups = RegisterGroup.class, message = "密码不能为空")
    private String password;
    @NotEmpty(groups = {UpdateGroup.class,RegisterGroup.class})
    @Schema(description = "邮箱")
    @Email(groups = UpdateGroup.class, message = "邮箱格式不正确")
    private String email;
    @Min(value = 1, groups = UpdateGroup.class, message = "年龄必须是正整数")
    private Integer age;
    @Schema(description = "手机号")
    @NotEmpty
    @CustomValidPhone(groups = RegisterGroup.class, message = "手机号格式不正确飒飒")
    private String phone;
}
